////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2017-2018 Qualcomm Technologies, Inc.
// All Rights Reserved.
// Confidential and Proprietary - Qualcomm Technologies, Inc.
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// THIS IS AUTO-GENERATED CODE.  PLEASE DO NOT EDIT (File bug reports against tools).
///
/// Auto-generated by: ParameterParser V1.1.4
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @file  afcontrastafelements.cpp
/// @brief Auto-generated Chromatix parameter file
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

#include "afcontrastafelements.h"
#include "parametersetmanager.h"

AFCONTRASTAFELEMENTS_NAMESPACE_BEGIN

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Default Constructor
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
chromatixContrastAFTypeClass::chromatixContrastAFTypeClass(
    const CHAR* name)
    : ParameterModule(name, MAJOR, MINOR, PATCH, 0, 0, 0, 0)
{
    PARAMETER_INITIALIZE(SymbolTableID);
    PARAMETER_INITIALIZE(module_version);
    PARAMETER_INITIALIZE(parameter_version);
    PARAMETER_INITIALIZE(statisticsSelection);
    PARAMETER_INITIALIZE(fullSweep);
    PARAMETER_INITIALIZE(singleSearch);
    PARAMETER_INITIALIZE(spotlightTuning);
    PARAMETER_INITIALIZE(weightedWindow);
    PARAMETER_INITIALIZE(exposureCompensation);
    PARAMETER_INITIALIZE(HVFocusValueStatisticWeighting);
    PARAMETER_INITIALIZE(stepBack);
    PARAMETER_INITIALIZE(secondScan);
    PARAMETER_INITIALIZE(flatnessDetection);
    PARAMETER_INITIALIZE(sceneChangeBV);
    PARAMETER_INITIALIZE(miscellaneous);
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Constructor
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
chromatixContrastAFTypeClass::chromatixContrastAFTypeClass(
    const CHAR* name,
    UINT32 modeId,
    UINT16 mode,
    UINT16 subMode,
    UINT32 group)
    : ParameterModule(name, MAJOR, MINOR, PATCH, modeId, mode, subMode, group)
{
    PARAMETER_INITIALIZE(SymbolTableID);
    PARAMETER_INITIALIZE(module_version);
    PARAMETER_INITIALIZE(parameter_version);
    PARAMETER_INITIALIZE(statisticsSelection);
    PARAMETER_INITIALIZE(fullSweep);
    PARAMETER_INITIALIZE(singleSearch);
    PARAMETER_INITIALIZE(spotlightTuning);
    PARAMETER_INITIALIZE(weightedWindow);
    PARAMETER_INITIALIZE(exposureCompensation);
    PARAMETER_INITIALIZE(HVFocusValueStatisticWeighting);
    PARAMETER_INITIALIZE(stepBack);
    PARAMETER_INITIALIZE(secondScan);
    PARAMETER_INITIALIZE(flatnessDetection);
    PARAMETER_INITIALIZE(sceneChangeBV);
    PARAMETER_INITIALIZE(miscellaneous);
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Destructor
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
chromatixContrastAFTypeClass::~chromatixContrastAFTypeClass()
{
    UnloadchromatixContrastAFType(this);
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// GetName
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
const CHAR* chromatixContrastAFTypeClass::GetName(
    const CHAR* type)
{
    const CHAR* name = type;
    CHAR temp[ParameterFileSymbolTableEntry::TYPE_LEN + 1];
    if (PARAMETER_STRCMP(type, ParameterFileSymbolTableEntry::GetType(temp, "chromatixContrastAF")) == 0)
    {
        name = "chromatixContrastAF";
    }
    return name;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load chromatixBAFExposureCompensation
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL chromatixContrastAFTypeClass::LoadchromatixBAFExposureCompensation(
    ParameterFileSymbolTableEntry* entry,
    chromatixBAFExposureCompensation* structure)
{
    BOOL result = TRUE;
    result = result && entry->ReadInt32(&structure->exposureCompensationEnable);
    result = result && entry->ReadInt32(&structure->kickinProgress);

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load chromatixAFMiscellaneousType
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL chromatixContrastAFTypeClass::LoadchromatixAFMiscellaneousType(
    ParameterFileSymbolTableEntry* entry,
    chromatixAFMiscellaneousType* structure)
{
    BOOL result = TRUE;
    result = result && entry->ReadInt32(&structure->peakDetectInDecreaseEnable);
    result = result && entry->ReadInt32(&structure->frameSkipGoToPeak);
    result = result && entry->ReadInt32(&structure->forceEnableFineSearch);
    result = result && entry->ReadInt32(&structure->optimizePrescan);
    result = result && entry->ReadInt32(&structure->optimizePeakEnable);

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load chromatixAFTuningFullsweep
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL chromatixContrastAFTypeClass::LoadchromatixAFTuningFullsweep(
    ParameterFileSymbolTableEntry* entry,
    chromatixAFTuningFullsweep* structure)
{
    BOOL result = TRUE;
    result = result && entry->ReadInt32(&structure->numStepsBetweenStatPoints);
    result = result && entry->ReadInt32(&structure->frameDelayInf);
    result = result && entry->ReadInt32(&structure->frameDelayNorm);
    result = result && entry->ReadInt32(&structure->frameDelayFinal);
    result = result && entry->ReadInt32(&structure->previewAssistedAFEnable);

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load chromatixStepSize
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL chromatixContrastAFTypeClass::LoadchromatixStepSize(
    ParameterFileSymbolTableEntry* entry,
    chromatixStepSize* structure)
{
    BOOL result = TRUE;
    result = result && entry->ReadUInt32(&structure->region0);
    result = result && entry->ReadUInt32(&structure->region1);
    result = result && entry->ReadUInt32(&structure->region2);
    result = result && entry->ReadUInt32(&structure->region3);
    result = result && entry->ReadUInt32(&structure->region4);

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load chromatixStepSizeTable
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL chromatixContrastAFTypeClass::LoadchromatixStepSizeTable(
    ParameterFileSymbolTableEntry* entry,
    chromatixStepSizeTable* structure)
{
    BOOL result = TRUE;
    result = result && LoadchromatixStepSize(entry, &structure->prescanNormalLight);
    result = result && LoadchromatixStepSize(entry, &structure->prescanLowLight);
    result = result && LoadchromatixStepSize(entry, &structure->finescanNormalLight);
    result = result && LoadchromatixStepSize(entry, &structure->finescanLowLight);

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load chromatixBVThreshold
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL chromatixContrastAFTypeClass::LoadchromatixBVThreshold(
    ParameterFileSymbolTableEntry* entry,
    chromatixBVThreshold* structure)
{
    BOOL result = TRUE;
    for (UINT32 i = 0; result && i < 8; i++)
    {
        result = result && entry->ReadFloat(&structure->Threshold[i]);
    }

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load chromatixSingleThreshold
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL chromatixContrastAFTypeClass::LoadchromatixSingleThreshold(
    ParameterFileSymbolTableEntry* entry,
    chromatixSingleThreshold* structure)
{
    BOOL result = TRUE;
    result = result && entry->ReadFloat(&structure->changeRatioInc);
    result = result && entry->ReadFloat(&structure->changeRatioDec);
    result = result && entry->ReadFloat(&structure->flatIncThres);
    result = result && entry->ReadFloat(&structure->flatDecThres);
    result = result && entry->ReadFloat(&structure->macroThres);
    result = result && entry->ReadFloat(&structure->dropThres);
    result = result && entry->ReadUInt32(&structure->histogramDecreaseDecreaseThreshold);
    result = result && entry->ReadUInt32(&structure->histogramIncreaseDecreaseThreshold);
    result = result && LoadchromatixBVThreshold(entry, &structure->threeFrameDecreaseDecreasePeakThreshold);
    result = result && LoadchromatixBVThreshold(entry, &structure->threeFrameIncreaseDecreasePeakThreshold);
    result = result && LoadchromatixBVThreshold(entry, &structure->decreaseDecreasePeakThreshold);
    result = result && LoadchromatixBVThreshold(entry, &structure->decreaseDecreasePeakWithNoiseThreshold);
    result = result && LoadchromatixBVThreshold(entry, &structure->increaseDecreasePeakThreshold);
    result = result && LoadchromatixBVThreshold(entry, &structure->increaseDecreasePeakWithNoiseThreshold);
    result = result && LoadchromatixBVThreshold(entry, &structure->flatThreshold);

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load chromatixFVScoreThreshold
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL chromatixContrastAFTypeClass::LoadchromatixFVScoreThreshold(
    ParameterFileSymbolTableEntry* entry,
    chromatixFVScoreThreshold* structure)
{
    BOOL result = TRUE;
    result = result && entry->ReadInt32(&structure->defaultStats);
    result = result && LoadchromatixBVThreshold(entry, &structure->scoreRatioShowDif);
    result = result && entry->ReadFloat(&structure->strictNoise);
    result = result && entry->ReadFloat(&structure->normalNoise);
    result = result && entry->ReadFloat(&structure->lighttNoise);
    result = result && entry->ReadInt32(&structure->strongPeakThres);
    result = result && entry->ReadInt32(&structure->strongIncThres);
    result = result && entry->ReadInt32(&structure->strongDecThres);

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load chromatixSingleOptic
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL chromatixContrastAFTypeClass::LoadchromatixSingleOptic(
    ParameterFileSymbolTableEntry* entry,
    chromatixSingleOptic* structure)
{
    BOOL result = TRUE;
    result = result && entry->ReadUInt32(&structure->CAFFarEnd);
    result = result && entry->ReadUInt32(&structure->CAFNearEnd);
    result = result && entry->ReadUInt32(&structure->TAFFarEnd);
    result = result && entry->ReadUInt32(&structure->TAFNearEnd);
    result = result && entry->ReadUInt32(&structure->searchRegion1);
    result = result && entry->ReadUInt32(&structure->searchRegion2);
    result = result && entry->ReadUInt32(&structure->searchRegion3);
    result = result && entry->ReadUInt32(&structure->fineSearchRegion);
    result = result && entry->ReadUInt32(&structure->farZone);
    result = result && entry->ReadUInt32(&structure->nearZone);
    result = result && entry->ReadUInt32(&structure->midZone);
    result = result && entry->ReadUInt32(&structure->farStartPosition);
    result = result && entry->ReadUInt32(&structure->nearStartPosition);
    result = result && entry->ReadUInt32(&structure->initialPosition);

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load chromatixAFSingleFrameDelay
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL chromatixContrastAFTypeClass::LoadchromatixAFSingleFrameDelay(
    ParameterFileSymbolTableEntry* entry,
    chromatixAFSingleFrameDelay* structure)
{
    BOOL result = TRUE;
    result = result && entry->ReadUInt32(&structure->baseFrameDelay);
    result = result && entry->ReadUInt32(&structure->coarseFrameDelay);
    result = result && entry->ReadUInt32(&structure->fineFrameDelay);

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load chromatixAFTuningSingle
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL chromatixContrastAFTypeClass::LoadchromatixAFTuningSingle(
    ParameterFileSymbolTableEntry* entry,
    chromatixAFTuningSingle* structure)
{
    BOOL result = TRUE;

    // Reading structure->index from the symbol table
    {
        result = result && entry->ReadUInt32(&structure->indexCount);
        structure->indexID = entry->ID;
        ParameterFileSymbolTableEntry* pointerEntry1 = entry->Table->ReadPointerEntry(entry);
        result = result && pointerEntry1 != NULL;
        if (result)
        {
            structure->index   = PARAMETER_NEW UINT32[structure->indexCount];
        }
        if (!result || structure->index == NULL)
        {
            structure->indexCount = 0;
        }
        for (UINT32 i = 0; result && i < structure->indexCount; i++)
        {
            result = result && pointerEntry1->ReadUInt32(&structure->index[i]);
        }
    }
    result = result && entry->ReadUInt32(&structure->actuatorType);
    result = result && entry->ReadUInt32(&structure->isHysteresisCompensationNeeded);
    result = result && entry->ReadUInt32(&structure->stepIndexPerMicroMeter);
    result = result && entry->ReadInt32(&structure->previewAssistedAFEnable);
    result = result && LoadchromatixStepSizeTable(entry, &structure->TAFStepTable);
    result = result && LoadchromatixStepSizeTable(entry, &structure->CAFStepTable);
    result = result && LoadchromatixSingleThreshold(entry, &structure->software);
    result = result && LoadchromatixSingleThreshold(entry, &structure->hardware);
    result = result && LoadchromatixSingleOptic(entry, &structure->optics);
    result = result && LoadchromatixFVScoreThreshold(entry, &structure->FVScoreThreshold);
    result = result && LoadchromatixAFSingleFrameDelay(entry, &structure->frameDelay);
    for (UINT32 i = 0; result && i < 8; i++)
    {
        result = result && entry->ReadFloat(&structure->BVGain[i]);
    }
    result = result && entry->ReadInt32(&structure->ignoreFirstInvalidFrame);

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load chromatixAFSpotlightReserveType
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL chromatixContrastAFTypeClass::LoadchromatixAFSpotlightReserveType(
    ParameterFileSymbolTableEntry* entry,
    chromatixAFSpotlightReserveType* structure)
{
    BOOL result = TRUE;
    result = result && entry->ReadInt32(&structure->enableSpotlightFilterSwitch);
    for (UINT32 i = 0; result && i < 10; i++)
    {
        result = result && entry->ReadFloat(&structure->secondOrderSpotlightFilterCoefficients[i]);
    }
    for (UINT32 i = 0; result && i < 10; i++)
    {
        result = result && entry->ReadFloat(&structure->fourthOrderSpotlightFilterCoefficients[i]);
    }

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load chromatixRegionTableType
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL chromatixContrastAFTypeClass::LoadchromatixRegionTableType(
    ParameterFileSymbolTableEntry* entry,
    chromatixRegionTableType* structure)
{
    BOOL result = TRUE;
    result = result && entry->ReadUInt32(&structure->numEntries);

    // Reading structure->weight from the symbol table
    {
        result = result && entry->ReadUInt32(&structure->weightCount);
        structure->weightID = entry->ID;
        ParameterFileSymbolTableEntry* pointerEntry1 = entry->Table->ReadPointerEntry(entry);
        result = result && pointerEntry1 != NULL;
        if (result)
        {
            structure->weight   = PARAMETER_NEW FLOAT[structure->weightCount];
        }
        if (!result || structure->weight == NULL)
        {
            structure->weightCount = 0;
        }
        for (UINT32 i = 0; result && i < structure->weightCount; i++)
        {
            result = result && pointerEntry1->ReadFloat(&structure->weight[i]);
        }
    }

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load chromatixLumaTableEntryType
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL chromatixContrastAFTypeClass::LoadchromatixLumaTableEntryType(
    ParameterFileSymbolTableEntry* entry,
    chromatixLumaTableEntryType* structure)
{
    BOOL result = TRUE;
    result = result && entry->ReadFloat(&structure->luma);
    result = result && entry->ReadFloat(&structure->weight);

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load chromatixLumaTableType
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL chromatixContrastAFTypeClass::LoadchromatixLumaTableType(
    ParameterFileSymbolTableEntry* entry,
    chromatixLumaTableType* structure)
{
    BOOL result = TRUE;
    result = result && entry->ReadUInt32(&structure->numEntries);

    // Reading structure->lumaEntries from the symbol table
    {
        result = result && entry->ReadUInt32(&structure->lumaEntriesCount);
        structure->lumaEntriesID = entry->ID;
        ParameterFileSymbolTableEntry* pointerEntry1 = entry->Table->ReadPointerEntry(entry);
        result = result && pointerEntry1 != NULL;
        if (result)
        {
            structure->lumaEntries   = PARAMETER_NEW chromatixLumaTableEntryType[structure->lumaEntriesCount];
        }
        if (!result || structure->lumaEntries == NULL)
        {
            structure->lumaEntriesCount = 0;
        }
        for (UINT32 i = 0; result && i < structure->lumaEntriesCount; i++)
        {
            result = result && LoadchromatixLumaTableEntryType(pointerEntry1, &structure->lumaEntries[i]);
        }
    }

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load chromatixFaceTableEntryType
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL chromatixContrastAFTypeClass::LoadchromatixFaceTableEntryType(
    ParameterFileSymbolTableEntry* entry,
    chromatixFaceTableEntryType* structure)
{
    BOOL result = TRUE;
    result = result && entry->ReadUInt32(&structure->fvIndex);
    result = result && entry->ReadFloat(&structure->weight);

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load chromatixFaceTableType
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL chromatixContrastAFTypeClass::LoadchromatixFaceTableType(
    ParameterFileSymbolTableEntry* entry,
    chromatixFaceTableType* structure)
{
    BOOL result = TRUE;
    result = result && entry->ReadUInt32(&structure->numEntries);

    // Reading structure->indexEntries from the symbol table
    {
        result = result && entry->ReadUInt32(&structure->indexEntriesCount);
        structure->indexEntriesID = entry->ID;
        ParameterFileSymbolTableEntry* pointerEntry1 = entry->Table->ReadPointerEntry(entry);
        result = result && pointerEntry1 != NULL;
        if (result)
        {
            structure->indexEntries   = PARAMETER_NEW chromatixFaceTableEntryType[structure->indexEntriesCount];
        }
        if (!result || structure->indexEntries == NULL)
        {
            structure->indexEntriesCount = 0;
        }
        for (UINT32 i = 0; result && i < structure->indexEntriesCount; i++)
        {
            result = result && LoadchromatixFaceTableEntryType(pointerEntry1, &structure->indexEntries[i]);
        }
    }

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load chromatixAFWeightedWindowReserveType
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL chromatixContrastAFTypeClass::LoadchromatixAFWeightedWindowReserveType(
    ParameterFileSymbolTableEntry* entry,
    chromatixAFWeightedWindowReserveType* structure)
{
    BOOL result = TRUE;
    result = result && entry->ReadInt32(&structure->enableAFRegionWeightTable);
    result = result && LoadchromatixRegionTableType(entry, &structure->AFRegionWeightTable);
    result = result && entry->ReadInt32(&structure->enableAFLumaWeightTable);
    result = result && LoadchromatixLumaTableType(entry, &structure->AFLumaWeightTable);
    result = result && entry->ReadInt32(&structure->enableAFFaceWeightTable);
    result = result && LoadchromatixFaceTableType(entry, &structure->AFFaceWeightTable);

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load chromatixAFStepBackReserveType
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL chromatixContrastAFTypeClass::LoadchromatixAFStepBackReserveType(
    ParameterFileSymbolTableEntry* entry,
    chromatixAFStepBackReserveType* structure)
{
    BOOL result = TRUE;
    result = result && entry->ReadInt32(&structure->stepBackEnable);
    result = result && entry->ReadInt32(&structure->stepBackStartInfinity);
    result = result && entry->ReadInt32(&structure->stepBackReverseInfinity);
    result = result && entry->ReadInt32(&structure->stepBackStartMacro);
    result = result && entry->ReadInt32(&structure->stepBackReverseMacro);

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load chromatixAFSecondScanReserveType
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL chromatixContrastAFTypeClass::LoadchromatixAFSecondScanReserveType(
    ParameterFileSymbolTableEntry* entry,
    chromatixAFSecondScanReserveType* structure)
{
    BOOL result = TRUE;
    result = result && entry->ReadFloat(&structure->fRatioMin);
    result = result && entry->ReadFloat(&structure->fRatioMax);
    result = result && entry->ReadFloat(&structure->firstPreviousY1);
    result = result && entry->ReadFloat(&structure->nextY1);
    result = result && entry->ReadFloat(&structure->firstPreviousY2);
    result = result && entry->ReadFloat(&structure->nextY2);
    result = result && entry->ReadFloat(&structure->secondPreviousY1);
    result = result && entry->ReadFloat(&structure->secondNextY1);
    result = result && entry->ReadFloat(&structure->secondPreviousY2);
    result = result && entry->ReadFloat(&structure->secondNextY2);

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load chromatixAFFlatDetectReserveType
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL chromatixContrastAFTypeClass::LoadchromatixAFFlatDetectReserveType(
    ParameterFileSymbolTableEntry* entry,
    chromatixAFFlatDetectReserveType* structure)
{
    BOOL result = TRUE;
    result = result && entry->ReadInt32(&structure->flatDetectSupportEnable);
    result = result && entry->ReadFloat(&structure->BVThresholdFlatDetect);
    result = result && entry->ReadFloat(&structure->flatIncreasingThreshold);
    result = result && entry->ReadFloat(&structure->flatDecreasingThreshold);

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load chromatixAFSceneChangeBVReserveType
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL chromatixContrastAFTypeClass::LoadchromatixAFSceneChangeBVReserveType(
    ParameterFileSymbolTableEntry* entry,
    chromatixAFSceneChangeBVReserveType* structure)
{
    BOOL result = TRUE;
    result = result && entry->ReadInt32(&structure->sceneChangeByBVEnable);
    result = result && entry->ReadFloat(&structure->BVUnstableThresholdOutdoor);
    result = result && entry->ReadFloat(&structure->BVStableThresholdOutdoor);
    result = result && entry->ReadFloat(&structure->BVTriggerCountThresholdOutdoor);
    result = result && entry->ReadFloat(&structure->BVUnstableThresholdNormalLux);
    result = result && entry->ReadFloat(&structure->BVStableThresholdNormalLux);
    result = result && entry->ReadFloat(&structure->BVTriggerCountThresholdNormalLux);
    result = result && entry->ReadFloat(&structure->BVUnstableThresholdLowLux);
    result = result && entry->ReadFloat(&structure->BVStableThresholdLowLux);
    result = result && entry->ReadFloat(&structure->BVTriggerCountThresholdLowLux);

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load chromatixAFHVStatWeightReserveType
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL chromatixContrastAFTypeClass::LoadchromatixAFHVStatWeightReserveType(
    ParameterFileSymbolTableEntry* entry,
    chromatixAFHVStatWeightReserveType* structure)
{
    BOOL result = TRUE;
    result = result && entry->ReadInt32(&structure->enableHVStatsRatio);
    result = result && entry->ReadFloat(&structure->hvFocusValueWeight);

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load chromatixContrastAFType
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL chromatixContrastAFTypeClass::LoadchromatixContrastAFType(
    ParameterFileSymbolTableEntry* entry,
    chromatixContrastAFType* structure)
{
    BOOL result = TRUE;
    result = result && Loadmodule_versionStruct(entry, &structure->module_version);
    result = result && Loadparameter_versionStruct(entry, &structure->parameter_version);
    structure->statisticsSelection = (AFStatisticComputationType)entry->ReadEnum(&result);
    result = result && LoadchromatixAFTuningFullsweep(entry, &structure->fullSweep);
    result = result && LoadchromatixAFTuningSingle(entry, &structure->singleSearch);
    result = result && LoadchromatixAFSpotlightReserveType(entry, &structure->spotlightTuning);
    result = result && LoadchromatixAFWeightedWindowReserveType(entry, &structure->weightedWindow);
    result = result && LoadchromatixBAFExposureCompensation(entry, &structure->exposureCompensation);
    result = result && LoadchromatixAFHVStatWeightReserveType(entry, &structure->HVFocusValueStatisticWeighting);
    result = result && LoadchromatixAFStepBackReserveType(entry, &structure->stepBack);
    result = result && LoadchromatixAFSecondScanReserveType(entry, &structure->secondScan);
    result = result && LoadchromatixAFFlatDetectReserveType(entry, &structure->flatnessDetection);
    result = result && LoadchromatixAFSceneChangeBVReserveType(entry, &structure->sceneChangeBV);
    result = result && LoadchromatixAFMiscellaneousType(entry, &structure->miscellaneous);

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load module_versionStruct
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL chromatixContrastAFTypeClass::Loadmodule_versionStruct(
    ParameterFileSymbolTableEntry* entry,
    chromatixContrastAFType::module_versionStruct* structure)
{
    BOOL result = TRUE;
    result = result && entry->ReadInt32(&structure->major_revision);
    result = result && entry->ReadInt32(&structure->minor_revision);

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load parameter_versionStruct
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL chromatixContrastAFTypeClass::Loadparameter_versionStruct(
    ParameterFileSymbolTableEntry* entry,
    chromatixContrastAFType::parameter_versionStruct* structure)
{
    BOOL result = TRUE;
    result = result && entry->ReadInt32(&structure->major_revision);
    result = result && entry->ReadInt32(&structure->minor_revision);

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Unload chromatixAFTuningSingle
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void chromatixContrastAFTypeClass::UnloadchromatixAFTuningSingle(
    chromatixAFTuningSingle* structure)
{
    PARAMETER_DELETE[] structure->index;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Unload chromatixRegionTableType
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void chromatixContrastAFTypeClass::UnloadchromatixRegionTableType(
    chromatixRegionTableType* structure)
{
    PARAMETER_DELETE[] structure->weight;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Unload chromatixLumaTableType
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void chromatixContrastAFTypeClass::UnloadchromatixLumaTableType(
    chromatixLumaTableType* structure)
{
    PARAMETER_DELETE[] structure->lumaEntries;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Unload chromatixFaceTableType
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void chromatixContrastAFTypeClass::UnloadchromatixFaceTableType(
    chromatixFaceTableType* structure)
{
    PARAMETER_DELETE[] structure->indexEntries;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Unload chromatixAFWeightedWindowReserveType
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void chromatixContrastAFTypeClass::UnloadchromatixAFWeightedWindowReserveType(
    chromatixAFWeightedWindowReserveType* structure)
{
    UnloadchromatixRegionTableType(&structure->AFRegionWeightTable);
    UnloadchromatixLumaTableType(&structure->AFLumaWeightTable);
    UnloadchromatixFaceTableType(&structure->AFFaceWeightTable);
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Unload chromatixContrastAFType
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void chromatixContrastAFTypeClass::UnloadchromatixContrastAFType(
    chromatixContrastAFType* structure)
{
    UnloadchromatixAFTuningSingle(&structure->singleSearch);
    UnloadchromatixAFWeightedWindowReserveType(&structure->weightedWindow);
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Parse symbol table entry, and return a new object
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
ParameterModule* chromatixContrastAFTypeClass::Parse(
    ParameterSetManager* manager,
    ParameterFileSymbolTableEntry* entry) const
{
    chromatixContrastAFTypeClass* cls = NULL;

    if (PARAMETER_STRCMP(Type, entry->Type) == 0 && Major == entry->Major &&
        Minor == entry->Minor && Patch == entry->Patch)
    {
        cls = PARAMETER_NEW chromatixContrastAFTypeClass(GetName(entry->Type), 
            entry->ModeId, entry->Mode, entry->SubMode, entry->Group);
        if (cls != NULL)
        {
            BOOL result = TRUE;

            cls->SymbolTableID = entry->ID;
            cls->ID            = entry->ID;

            result = result && LoadchromatixContrastAFType(entry, cls);

            if (!result)
            {
                PARAMETER_DELETE cls;
                cls = NULL;
            }
        }
    }
    return (ParameterModule*)cls;
}


AFCONTRASTAFELEMENTS_NAMESPACE_END
